package com.winter.main.mapper.master.system;

import com.winter.main.model.entity.SysRole;
import com.winter.main.model.entity.SysUser;
import com.winter.main.utils.MyMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Desc:
 * Author: dushuang
 * Date: Create in 2018/4/18
 */
public interface SysRoleMapper extends MyMapper<SysRole> {

    @Select({"<script>" ,
            "SELECT ",
            "sr.id,",
            "role_code AS roleCode,",
            "role_name AS roleName,",
            "role_desc AS roleDesc ",
            "FROM sys_role sr ",
            "LEFT JOIN sys_user_role sur ON sur.role_id = sr.id ",
            "LEFT JOIN sys_user su ON su.id = sur.user_id ",
            "WHERE su.id = #{id} ",
            "</script>"})
    List<SysRole> selectRoleByUser(SysUser user);

}
